﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Kaskelot.Services.Model;

namespace Stockholm.SOA.Kaskelot.WCF.ServiceImplementation.Mapping
{
	public static class MaterielTypExtensions
	{
		public static DataContracts.MaterielTyp ToContract(this MaterielTyp entity)
		{
			DataContracts.MaterielTyp b = new DataContracts.MaterielTyp();

			CopyFromEntity(entity, b, false);

			return b;
		}

		public static DataContracts.MaterielTyp ToMinimalContract(this MaterielTyp entity)
		{
			DataContracts.MaterielTyp b = new DataContracts.MaterielTyp();

			CopyFromEntity(entity, b, true);

			return b;
		}

		public static MaterielTyp ToEntity(this DataContracts.MaterielTyp b)
		{
			MaterielTyp entity = new MaterielTyp();

			CopyToEntity(b, entity);

			return entity;
		}

		public static void UpdateEntity(this MaterielTyp entity, DataContracts.MaterielTyp mt)
		{
			CopyToEntity(mt, entity);
		}

		private static void CopyFromEntity(MaterielTyp from, DataContracts.MaterielTyp to, bool minimal)
		{
			to.Id = from.Id;
			to.ValId = from.ValId;
			to.Beskrivning = from.Beskrivning;
			to.VisaILista = from.VisaILista;

			to.Andrad = from.Andrad;
			to.AndradAv = from.AndradAv;
			to.Skapad = from.Skapad;
			to.SkapadAv = from.SkapadAv;
		}

		private static void CopyToEntity(DataContracts.MaterielTyp from, MaterielTyp to)
		{
			to.Id = from.Id;
			to.ValId = from.ValId;
			to.Beskrivning = from.Beskrivning;
			to.VisaILista = from.VisaILista;

			to.Andrad = from.Andrad;
			to.AndradAv = from.AndradAv;
			to.Skapad = from.Skapad;
			to.SkapadAv = from.SkapadAv;
		}
	}
}
